package com.ruoyi.web.controller.basicInfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basicInfo.domain.WarehouseCoal;
import com.ruoyi.basicInfo.service.IWarehouseCoalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓储煤种信息Controller
 * 
 * @author zbw
 * @date 2022-07-16
 */
@RestController
@RequestMapping("/basicInfo/warehouseCoal")
public class WarehouseCoalController extends BaseController
{
    @Autowired
    private IWarehouseCoalService warehouseCoalService;

    /**
     * 查询仓储煤种信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseCoal warehouseCoal)
    {
        startPage();
        List<WarehouseCoal> list = warehouseCoalService.selectWarehouseCoalList(warehouseCoal);
        return getDataTable(list);
    }

    /**
     * 导出仓储煤种信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:export')")
    @Log(title = "仓储煤种信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseCoal warehouseCoal)
    {
        List<WarehouseCoal> list = warehouseCoalService.selectWarehouseCoalList(warehouseCoal);
        ExcelUtil<WarehouseCoal> util = new ExcelUtil<WarehouseCoal>(WarehouseCoal.class);
        util.exportExcel(response, list, "仓储煤种信息数据");
    }

    /**
     * 获取仓储煤种信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(warehouseCoalService.selectWarehouseCoalById(id));
    }

    /**
     * 新增仓储煤种信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:add')")
    @Log(title = "仓储煤种信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehouseCoal warehouseCoal)
    {
        return toAjax(warehouseCoalService.insertWarehouseCoal(warehouseCoal));
    }

    /**
     * 修改仓储煤种信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:edit')")
    @Log(title = "仓储煤种信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehouseCoal warehouseCoal)
    {
        return toAjax(warehouseCoalService.updateWarehouseCoal(warehouseCoal));
    }

    /**
     * 删除仓储煤种信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:warehouseCoal:remove')")
    @Log(title = "仓储煤种信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(warehouseCoalService.deleteWarehouseCoalByIds(ids));
    }
}
